package com.start.config;

import com.xr.filter.AccessFilter;
import com.xr.handle.ResponseBodyWrapFactoryBean;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;

/**
 * @author Arnold Yand
 * @summary invest api 相关配置
 * @time 2018/4/5 19:33
 */
@org.springframework.context.annotation.Configuration
public class Configuration {

  /**
   * 封装@ResponseBody注解返回的信息为自定义格式
   * see com.xr.dto.ResultDto
   * @return
   */
  @Bean
  public ResponseBodyWrapFactoryBean getResponseBodyWrap() {
    return  new ResponseBodyWrapFactoryBean();
  }

  @Bean
  public FilterRegistrationBean testFilterRegistration() {
    FilterRegistrationBean registration = new FilterRegistrationBean();
    registration.setFilter(new AccessFilter());
    registration.addUrlPatterns("/*");
    registration.setName("accessFilter");
    registration.setOrder(1);
    return registration;
  }
}
